155

Advanced Graphics

155

STEP 7 continued

    UserForm1.TextBox1.ForeColor =​ vbRed

    UserForm1.Caption =​ “ COVID -​ Wrong input: Try Again!”

    ErrorInput =​ “Y”

End If

If ConfirmedOrDeaths =​ “C” Then

    NameOfChart =​ “Covid Cases Confirmed”

Else

    NameOfChart =​ “Covid Deaths Confirmed”

End If

ActiveSheet.Shapes.AddChart2(227, xlLine).Select

If SpecificState(0) =​ ““ Or SpecificStateColumn =​ ““ Then

    mm =​ thisWb.Sheets(“States”).Cells(2, 7) -​ 1

Else

    mm =​ SpecificStateColumn

End If

ActiveChart.SetSourceData Source:=​Range(thisWs.Cells(startrow(1), 2 * mm),

thisWs.Cells(j, 2 * mm))

ActiveChart.Parent.Name =​ NameOfChart

ActiveChart.ChartTitle.Text =​ NameOfChart

ActiveSheet.Shapes(NameOfChart).Left =​ 1

ActiveSheet.Shapes(NameOfChart).Top =​ 1

ActiveSheet.Shapes(NameOfChart).ScaleWidth 2.7, msoFalse, _​

    msoScaleFromTopLeft

ActiveSheet.Shapes(NameOfChart).ScaleHeight 1.5, msoFalse, _​

    msoScaleFromBottomRight

ActiveSheet.ChartObjects(NameOfChart).Chart.HasLegend =​ True

ActiveSheet.ChartObjects(NameOfChart).Chart.Legend.Position =​ xlBottom

ActiveChart.Axes(xlValue).MajorGridlines.Select

Continue drawing the first state in the second chart.

Set rRange =​ Range(thisWs.Cells(1, 2 * mm), thisWs.Cells(1, 2 * mm))

ActiveChart.SeriesCollection(1).Name =​ “=​‘Any State’!” & rRange.Address(True,

True, xlR1C1)

Set rRange =​ Range(thisWs.Cells(startrow(1), 2 * mm), thisWs.Cells(j, 2 * mm))

ActiveChart.SeriesCollection(1).Values =​ “=​‘Any State’!” & rRange.Address(True,

True, xlR1C1)

Set rRange =​ Range(thisWs.Cells(startrow(1), 1), thisWs.Cells(j, 1))

ActiveChart.SeriesCollection(1).XValues =​ “=​‘Any State’!” & rRange.

Address(True, True, xlR1C1)

Paint the US map.

‘ First get the map

fileopenMapWb.Sheets(“MAPS”).Shapes(“Group 57”).Copy

fileopenMapWb.Close

thisWsGraphs.Activate

thisWsGraphs.Range(“o1”).Select

ActiveSheet.Paste